package com.ruoyi.yipaiju.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.yipaiju.service.IDatavService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/yipaiju/datav")
public class DatavController {

    @Autowired
    private IDatavService datavService;


    @GetMapping("/basicsInfo")
    public AjaxResult getBasicsInfo(){
        return  AjaxResult.success(datavService.getBasicsInfo());
    }

    @GetMapping("/invitePeople")
    public AjaxResult getInvitePeople(){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String queryTime = df.format(DateUtils.addDays(new Date(), -7));
        return  AjaxResult.success( datavService.getInvitePeople( queryTime));
    }
    @GetMapping("/probability")
    public AjaxResult getProbability(@RequestParam(defaultValue = "12") Integer diffTime, String province, String city, String district){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
        String format = df.format(DateUtils.addMonths(new Date(), -diffTime));
        return  AjaxResult.success(datavService.getProbability(diffTime, format, province, city, district));
    }
    @GetMapping("/auctionNum")
    public AjaxResult getAuctionNum(@RequestParam(defaultValue = "12") Integer diffTime, String province, String city, String district){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
        String format = df.format(DateUtils.addMonths(new Date(), -diffTime));
        return  AjaxResult.success(datavService.getAuctionNum(diffTime, format, province, city, district));
    }
    @GetMapping("/auctionMoney")
    public AjaxResult getAuctionMoney(@RequestParam(defaultValue = "12") Integer diffTime, String province, String city, String district){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
        String format = df.format(DateUtils.addMonths(new Date(), -diffTime));
        return  AjaxResult.success(datavService.getAuctionMoney(diffTime, format,province, city, district));
    }
}
